package client.gui.roombox;

import stalker.Stalker;
import client.network.ServiceRequestCenter;
import data.Data;

public class RoomBox {
  
  private final RoomBoxController view_and_controller_;
  private final RoomBoxModel model_;
  private final Stalker room_;
  
  public RoomBox(Stalker room, ServiceRequestCenter servicer) {
    assert (room != null && servicer != null);
    room_ = room;
    model_ = new RoomBoxModel(room);
    view_and_controller_ = new RoomBoxController(room, servicer, model_);
    servicer.requestRoomDatas(room);
  }
  
  public boolean isVisible() {
    return view_and_controller_.isVisible();
  }
  
  public void setVisible(boolean status) {
    view_and_controller_.setVisible(status);
  }
  
  public Stalker getRoom() {
    return room_;
  }
  
  public void receiveData(Stalker sender, Data data) {
    assert (sender != null && data != null);
    if (!(sender.equals(room_))) {
      return;
    }
    model_.addData(data);
  }
  
}
